/**
 * @param {number} n - a positive integer
 * @return {number}
 */
 var hammingWeight = function(n) {
    let count = 0;
    let i = 1;
    n = parseInt(n, 2);
    while (i < n && i > 0) {
        if (n & i) {
            count++;
        }
        i = i << 1;
    }
    return (n & i) ? count + 1 : count;
};
